package com.pro.common.api.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.pro.framework.api.model.IBaseModel;
import com.pro.framework.api.model.IdsModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.io.Serial;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseModel implements IBaseModel, IdsModel {
    @Serial
    private static final long serialVersionUID = 10000L;

    public static final String field_createTime = "createTime";
    public static final String field_updateTime = "updateTime";
    public static final String field_deleted = "deleted";

    @Schema(description = "主键id")
    @TableId
    private Long id;

    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    protected LocalDateTime createTime;

    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.UPDATE)
    protected LocalDateTime updateTime;

    @Schema(description = "删除")
    protected Boolean deleted;


    /**
     * 批量操作时
     */
    @Schema(description = "主键ids")
    transient protected List<Long> ids;

//    public List<Long> toIds() {
//        List<Long> ids = getIds();
//        if (ids == null) {
//            ids = new ArrayList<>();
//        }
//        if (id != null) {
//            ids.add(id);
//        }
//        return ids;
//    }
}
